var chance_bottom_ul = document.querySelector(".chance_bottom ul");

function _ajax_gd() {
    var xhr2 = new XMLHttpRequest();
    xhr2.open("GET", "http://student.0melon0.cn/index/wheel/get_draw_record_list?page=4&page_num=15");
    xhr2.send();
    xhr2.addEventListener("readystatechange", function () {
        if (xhr2.readyState == 4 && xhr2.status == 200) {
            data = JSON.parse(xhr2.responseText);
            // console.log(data);
            data.data.draw_record_list.forEach((val) => {
                chance_bottom_ul.innerHTML += `<li>
                                            <span>${formatDate(new Date(val.draw_time_stamp * 1000))}</span>
                                            <span>${val.prize_name}</span>
                                            </li>`;
            })
        }
    })
}
_ajax_gd();
chance_bottom_ul.addEventListener("scroll",function(){
   ((Math.ceil(chance_bottom_ul.scrollTop)+chance_bottom_ul.clientHeight) == (chance_bottom_ul.scrollHeight))&&(_ajax_gd());

})
function formatDate(now) {
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var date = now.getDate();
    var hour = now.getHours();
    var minute = now.getMinutes();
    return year + "." + month + "." + date + " " + hour + ":" + minute;
} 